import java.util.ArrayList;


public class MovieLister {
	
	private IMovieFinder movieFinder;
	private Movie[] foundMovies;
	
	public Movie[] getFoundMovies() {
		return foundMovies;
	}

	public void setMovieFinder(IMovieFinder movieFinder) {
		this.movieFinder = movieFinder;
	}

	public MovieLister(IMovieFinder movieFinder){
			this.movieFinder = movieFinder;
	}
	
	public void moviesDirectedBy(String director){
		ArrayList<Movie> allMovies = this.movieFinder.findall();
		ArrayList<Movie> filteredMovies = new ArrayList<Movie>();
		
		for(int i = 0; i < allMovies.size(); i++){
			if(allMovies.get(i).getDirector().equals(director)){
				filteredMovies.add(allMovies.get(i));
			}
		}
		
		this.foundMovies = filteredMovies.toArray(new Movie[filteredMovies.size()]);
	}
}
